url = 'https://www.acwing.com/problem/content/791/'

## 方法一，由于数据连续的，所以采用dict来记录每个数的开始位置和结束位置

n,m = map(lambda x:int(x),input().split(" "))
data = list(map(lambda x:int(x),input().split(" ")))

d_dict = {}
n = 0
for i in range(len(data)):
    if data[i] != n:
        n = data[i]
        d_dict[data[i]] = [i,i]
    else:
        d_dict[data[i]][-1] = i

# print(d_dict)

for i in range(m):
    z = int(input())
    if d_dict.get(z):
        print(*d_dict[z])
    else:
        print(-1,-1)

## 方法二，二分

n, m = map(int, input().split())
q = list(map(int, input().split()))

for i in range(m):
    x = int(input())

    l, r = 0, n - 1
    while l < r:
        mid = (l + r) // 2
        if q[mid] >= x:
            r = mid
        else:
            l = mid + 1

    if q[l] != x:
        print("-1 -1")
    else:
        print(l, end=" ")

        l, r = 0, n - 1
        while l < r:
            mid = (l + r + 1) // 2
            if q[mid] <= x:
                l = mid
            else:
                r = mid - 1

        print(l)
